package flc.ast.adapter;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.TimeZone;

import flc.ast.R;
import flc.ast.utils.BitmapUtil;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkExchangeRateBean;

public class CurrencyAdapter extends StkProviderMultiAdapter<StkExchangeRateBean> {

    public CurrencyAdapter() {
        addItemProvider(new StkSingleSpanProvider(30));
        addItemProvider(new CurrencyProvider());
    }

    private class CurrencyProvider extends BaseItemProvider<StkExchangeRateBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_currency;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkExchangeRateBean bean) {
            String imageUri = "flag/" + bean.code.toLowerCase() + ".png";
            Bitmap imageFromAssetsFile = BitmapUtil.getImageFromAssetsFile(getContext(), imageUri);
            Glide.with(getContext()).load(imageFromAssetsFile == null ? R.drawable.mrgq1 : imageFromAssetsFile).into((ImageView) baseViewHolder.getView(R.id.ivCurrencyItemImg));
            baseViewHolder.setText(R.id.tvCurrencyItemName, bean.name + "(" + bean.code + ")");
        }
    }
}
